home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / perl / 5.10.0 / auto / DynaLoader / dl_findfile.al < prev   
Encoding:
Text File  |  2009-06-26  |  2.9 KB  |  87 lines

  1. # NOTE: Derived from ../../lib/DynaLoader.pm.
  2. # Changes made here will be lost when autosplit is run again.
  3. # See AutoSplit.pm.
  4. package DynaLoader;
  5.  
  6. #line 242 "../../lib/DynaLoader.pm (autosplit into ../../lib/auto/DynaLoader/dl_findfile.al)"
  7. sub dl_findfile {
  8.     # Read ext/DynaLoader/DynaLoader.doc for detailed information.
  9.     # This function does not automatically consider the architecture
  10.     # or the perl library auto directories.
  11.     my (@args) = @_;
  12.     my (@dirs,  $dir);   # which directories to search
  13.     my (@found);         # full paths to real files we have found
  14.     #my $dl_ext= 'so'; # $Config::Config{'dlext'} suffix for perl extensions
  15.     #my $dl_so = 'so'; # $Config::Config{'so'} suffix for shared libraries
  16.  
  17.     print STDERR "dl_findfile(@args)\n" if $dl_debug;
  18.  
  19.     # accumulate directories but process files as they appear
  20.     arg: foreach(@args) {
  21.         #  Special fast case: full filepath requires no search
  22.     
  23.     
  24.     
  25.         if (m:/: && -f $_) {
  26.         push(@found,$_);
  27.         last arg unless wantarray;
  28.         next;
  29.     }
  30.     
  31.  
  32.         # Deal with directories first:
  33.         #  Using a -L prefix is the preferred option (faster and more robust)
  34.         if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
  35.  
  36.     
  37.     
  38.         #  Otherwise we try to try to spot directories by a heuristic
  39.         #  (this is a more complicated issue than it first appears)
  40.         if (m:/: && -d $_) {   push(@dirs, $_); next; }
  41.  
  42.     
  43.  
  44.         #  Only files should get this far...
  45.         my(@names, $name);    # what filenames to look for
  46.         if (m:-l: ) {          # convert -lname to appropriate library name
  47.             s/-l//;
  48.             push(@names,"lib$_.so");
  49.             push(@names,"lib$_.a");
  50.         } else {                # Umm, a bare name. Try various alternatives:
  51.             # these should be ordered with the most likely first
  52.             push(@names,"$_.so")    unless m/\.so$/o;
  53.             push(@names,"$_.so")     unless m/\.so$/o;
  54.             push(@names,"lib$_.so")  unless m:/:;
  55.             push(@names,"$_.a")          if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
  56.             push(@names, $_);
  57.         }
  58.     my $dirsep = '/';
  59.     
  60.         foreach $dir (@dirs, @dl_library_path) {
  61.             next unless -d $dir;
  62.         
  63.             foreach $name (@names) {
  64.         my($file) = "$dir$dirsep$name";
  65.                 print STDERR " checking in $dir for $name\n" if $dl_debug;
  66.         $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
  67.         #$file = _check_file($file);
  68.         if ($file) {
  69.                     push(@found, $file);
  70.                     next arg; # no need to look any further
  71.                 }
  72.             }
  73.         }
  74.     }
  75.     if ($dl_debug) {
  76.         foreach(@dirs) {
  77.             print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
  78.         }
  79.         print STDERR "dl_findfile found: @found\n";
  80.     }
  81.     return $found[0] unless wantarray;
  82.     @found;
  83. }
  84.  
  85. # end of DynaLoader::dl_findfile
  86. 1;
  87.